package com.github.binarywang.demo.wechat.controller;

import com.github.binarywang.demo.wechat.model.Refer;
import com.github.binarywang.demo.wechat.service.WxReferService;
import com.github.binarywang.demo.wechat.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({ "wechat/refer" })
@RestController
public class WxReferController {
	@Autowired
	private WxReferService wxReferService;

	@GetMapping({ "insert" })
	public int insert(Refer refer) {
		return this.wxReferService.insert(refer);
	}

	@GetMapping({ "list" })
	public String list() {
		return JsonUtils.toJson(this.wxReferService.list());
	}

	@GetMapping({ "findById" })
	public String findByCourseId(Integer courseId) {
		return JsonUtils.toJson(this.wxReferService.selectByCourseId(courseId));
	}

	@GetMapping({ "delete" })
	public int delete(Integer courseId) {
		return this.wxReferService.delete(courseId);
	}

	@GetMapping({ "edit" })
	public int edit(Refer refer) {
		return this.wxReferService.edit(refer);
	}
}
